<#macro menuTree menus>
    <#if menus?? && menus?size gt 0>
        <#list menus as md>
            <#if md.hasChildren>
                <li class="nav-header">${md.name!}</li>
                <#list md.children as item>
                    <li class="nav-item">
                        <a href="${item.url!'#'}" class="nav-link">
                            ${item.icon!}
                            <p>
                                ${item.name!}
                                <#if item.hasChildren>
                                    <i class="fas fa-angle-left right"></i>
                                </#if>
                            </p>
                        </a>
                        <@menuChildren children=item.children></@menuChildren>
                    </li>
                </#list>
            </#if>
        </#list>
    </#if>
</#macro>

<#macro menuChildren children>
    <#if children?? && children?size gt 0>
        <ul class="nav nav-treeview">
            <#list children as child>
                <li class="nav-item">
                    <a href="${child.url!'#'}" class="nav-link">
                        <p>${child.name!}
                            <#if child.hasChildren>
                                <i class="fas fa-angle-left right"></i>
                            </#if>
                        </p>
                    </a>
                    <#if child.children?? && child.children?size gt 0>
                        <@menuChildren children=child.children></@menuChildren>
                    </#if>
                </li>
            </#list>
        </ul>
    </#if>
</#macro>

<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <a href="/" target="_blank" class="brand-link">
        <img src="/static/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
        <span class="brand-text font-weight-light">Jeegot</span>
    </a>

    <div class="sidebar">
        <nav class="mt-2">
            <ul id="sidebar-menu" class="nav nav-pills nav-flat nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">

                <li class="nav-item menu-open">
                    <a href="/admin/index" class="nav-link">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>首页</p>
                    </a>
                </li>

                <@adminMenu>
                    <@menuTree menus = data></@menuTree>
                </@adminMenu>

            </ul>
        </nav>
    </div>
</aside>